package cn.hh.service.impl;


import cn.hh.course.domain.Course;
import cn.hh.god.domain.Buy;
import cn.hh.mapper.CourseMapper;
import cn.hh.service.ICourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Random;

@Service
public class CourseServiceImpl implements ICourseService {
    @Autowired
    private CourseMapper courseMapper;
    @Override
    @Transactional
    public void save(Course course) {
        // 获取6为随机数
        Random random = new Random();
        String result="";
        for (int i=0;i<6;i++)
        {
            result+=random.nextInt(10);
        }
        courseMapper.save(course);
    }

    @Override
    public Course getById(Long id) {
        return courseMapper.getById(id);
    }

    @Override
    @Transactional
    public void updateById(Buy buy) {
        courseMapper.updateById(buy);
    }
}
